<?php
/**
 * @Author:      lyt
 * @DateTime:  2017-05-16 15:39:55
 * @Description: 用于充值记录的消费退款记录
 */
class AcountUserRechargeSpendRe extends Eloquent
{

    public static $type=array(
        1=>"订单退款" ,
        2=>"洗车单退款",
        3=>"订单支付撤销退款",
        4=>"洗车单支付撤销退款",
        5=>"套餐卡支付撤销退款",
        6=>"应收收回撤销支付退款",
        7=>"套餐卡退款",
    );
    protected $table = "acount_user_recharge_spendre_record";
    
        /**
         * @Author:      zy
         * @DateTime:  2017-07-14 15:34:59
         * @Description: 洗车单支付统计
         */
        public static function returnSpendMoney($shop_id,$start_time,$end_time){
            $record = DB::select("SELECT a.id,a.aurr_id,sum(a.amount) AS amount
                FROM  acount_user_recharge_spendre_record as a
                LEFT JOIN return_washorder_record b ON a.buss_id = b.id
                LEFT JOIN return_carwash_order c ON c.id = b.return_washorder_id
                WHERE a.shop_id = ? AND c.implement_time  BETWEEN ? AND ? 
                AND c.`status` = 1 and a.type=2 and b.pay_type=8 group by a.id",
                array($shop_id,$start_time,$end_time));
            return $record;
        }
        
        /**
         * @Author:      zy
         * @DateTime:  2017-07-14 15:34:59
         * @Description: 洗车单退款相关信息
         */
        public static function returnOrderSpendMoney($order_id){
            $record = DB::select("SELECT a.id,a.aurr_id,a.amount AS amount
                FROM  acount_user_recharge_spendre_record as a
                LEFT JOIN return_washorder_record b ON a.buss_id = b.id
                LEFT JOIN return_carwash_order c ON c.id = b.return_washorder_id
                WHERE c.id = ? AND a.type=2",
                array($order_id));
            return $record;
        }

}